package com.example.springbootautoconfig.EventPublisher;

import com.example.springbootautoconfig.AutoConfig.Lab2AutoConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.security.auth.callback.TextOutputCallback;

public class AppReadyEvent {

    @Component
    static class AppNoticeListener implements ApplicationListener<ApplicationReadyEvent>{

        private static final Logger logger = LoggerFactory.getLogger((AppNoticeListener.class));

        @Override
        public void onApplicationEvent(ApplicationReadyEvent noticeEvent) {
            logger.info("监听器获取到 NoticeEvent，睡眠当前线程三秒");
            try{
                Thread.sleep(3000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            logger.info("属性是： {}", noticeEvent.getSource());

        }
    }
}
